<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	    
					 <input type="text" id="num1"/>  
						<select id="cal">          
						<option value="1">+</option>           
						<option value="2">-</option> 
						 <option value="3">*</option>
						 <option value="4">%</option>
						  </select>       
						 <input type="text" id="num2" />        
						 <input type="button" id="btn" value="计算"/>             
						 <h2 id="result"></h2>               
						  <script>          
							document.getElementById("btn").onclick=function(){                                                                     
											                  
							var a=parseFloat(document.getElementById('num1').value);             
							var b=parseFloat(document.getElementById('num2').value);            
							var k=document.getElementById('cal').value;               
									console.log(a,b,k);               
					switch(k){  case "1":  document.getElementById('result').innerHTML=a+b; break;  case "2":                        
					document.getElementById('result').innerHTML=a-b;                       
					 break;                    case "3":
					   document.getElementById('result').innerHTML=a*b;                    
						   break;                  
						 case "4":  if(b==0){                            
						 alert("除数不能为0");                           
						return;                        }                        
					else{ document.getElementById('result').innerHTML=a/b;  }                       
					 break;                }            }      
									 </script>
	</body>
</html>
